#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 2018/8/31 13:40
# @Author  : supuchun
# @Site    : 
# @File    : quanjing.py

import os
import re
import time,json
import requests
from selenium import webdriver
from bs4 import BeautifulSoup

from selenium.common.exceptions import TimeoutException
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.action_chains import ActionChains
def get_driver_by_proxy():
    options = webdriver.ChromeOptions()

    # 设置图片不显示
    #prefs = {"profile.managed_default_content_settings.images":2}
    #options.add_experimental_option("prefs",prefs)
    #options.add_argument('--headless')
    driver = webdriver.Chrome(chrome_options=options)

    #设置页面打开超时 时间， 15s
    driver.set_page_load_timeout(15)

    return driver
def main():
    url = "http://www.quanjing.com/search.aspx?q=ul1076-1400"
    print url
    driver = get_driver_by_proxy()

    driver.get(url)
    driver.refresh()
    driver.implicitly_wait(2)
    soup = BeautifulSoup(driver.page_source, 'html.parser')
    print type(soup)
    #print soup
    body = soup.find_all(class_='gallery_list',)
    print body
    for i in body:
        for j in i.find_all("img"):
            print j.get('m')
            print j['src']
if __name__ == '__main__':
    main()
